function Tab(onshow, onhide, element)
{
    this.onshow = onshow;
    this.onhide = onhide;
    this.element = element;
}

function Tabs(element, tabs)
{
    this.element = element;
    this.tabs = tabs;
    this.currentTab = null;
    
    this.changeTab = function(tab)
    {
        if(this.currentTab)
        {
            this.element.removeChild(this.currentTab.element);
            this.currentTab.onhide();
        }
        
        this.element.appendChild(tab.element);
        this.currentTab = tab;
        tab.onshow();
        
    }

    // initialization side effects
    element.style.display = "block";
    for(var i in tabs) element.removeChild(tabs[i].element);
}


